package edu.xidian.sselab.cloudcourse.controller;

import edu.xidian.sselab.cloudcourse.domain.test10_entity;
import edu.xidian.sselab.cloudcourse.repository.test10_Repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class test10_controller {
    @Autowired
    private test10_Repository test10_repository;

    @RequestMapping("/test10")
    public String test10_try(Model model){
        model.addAttribute("title", "MPV各系车辆每月销量走势");
        return "test10";
    }

    @RequestMapping("/test26")
    public @ResponseBody
    Map test10_try2() throws IOException {

        String nation = "自主"; //车级别，MPV

        String start_time = "201907"; //开始时间

        String end_time = "202006"; //结束时间

        List<test10_entity> recordList1 = test10_repository.find(nation,start_time,end_time);
        List<test10_entity> recordList2 = test10_repository.find("德系",start_time,end_time);
        List<test10_entity> recordList3 = test10_repository.find("美系",start_time,end_time);
        List<test10_entity> recordList4 = test10_repository.find("日系",start_time,end_time);
        Map<String,List> map=new HashMap<>();
        map.put("自主",recordList1);
        map.put("德系",recordList2);
        map.put("美系",recordList3);
        map.put("日系",recordList4);

        System.out.println("以下是自主车系MPV车型201907到202006的销量情况：");

            System.out.println(map);

        return map;
    }
}
